unit Color;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ColorGrd, ExtCtrls;

type
  TFormColor = class(TForm)
    ColorGrid: TColorGrid;
    BtnOK: TBitBtn;
    BtnCancel: TBitBtn;
    Bevel1: TBevel;
    LabelColor: TLabel;
    Panel1: TPanel;
    Label1: TLabel;
    procedure ColorGridChange(Sender: TObject);
    procedure BtnOKClick(Sender: TObject);
    procedure BtnCancelClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    findex, bindex: integer;
  end;

var
  FormColor: TFormColor;

implementation

uses Database;

{$R *.DFM}

procedure TFormColor.ColorGridChange(Sender: TObject);
begin
  findex:=colorgrid.foregroundindex;
  bindex:=colorgrid.backgroundindex;
  LabelColor.font.color:=Datawell.FigureColor(findex);
  LabelColor.color:=Datawell.FigureColor(bindex);
end;

procedure TFormColor.BtnOKClick(Sender: TObject);
begin
  if findex = bindex then begin
    if messagedlg('Are you sure you want the foreground and background to be identical?',
      mtconfirmation,[mbyes,mbno],0) = mrno then exit;
  end;
  close;
end;

procedure TFormColor.BtnCancelClick(Sender: TObject);
begin
  findex:=-1;
  bindex:=-1;
  close;
end;

end.
